Why wouldn't `new int[x]{}` be valid???
Posted
by dboarman-FissureStudios
on Stack Overflow
See other posts from Stack Overflow
or by dboarman-FissureStudios
Published on 2010-05-16T21:39:14Z
Indexed on
2010/05/16
21:50 UTC
Read the original article
Hit count: 273
In MonoDevelop I have the following code which compiles:
int[] row = new int[indices.Count]{};
However, at run-time, I get:
Matrix.cs(53,53): Error CS0150: A constant value is expected (CS0150) (testMatrix)
I know what this error means and forces me to then resize the array:
int[] row = new int[indices.Count]{};
Array.Resize(ref row, rowWidth);
Is this something I just have to deal with because I am using MonoDevelop on Linux? I was certain that under .Net 3.5 I was able to initialize an array with a variable containing the width of the array. Can anyone confirm that this is isolated? If so, I can report the bug to bugzilla.
© Stack Overflow or respective owner